package com.base.system.base.db.specifications;

import javax.persistence.criteria.*;

public class GtSpecification<T> extends AbstractSpecification<T> {

    private static final long serialVersionUID = 5849610770444323151L;
    private final String property;
    private final Number value;

    public GtSpecification(String property, Number value, JoinType joinType) {
        this.property = property;
        this.value = value;
        this.joinType = joinType;
    }

    @Override
    public Predicate toPredicate(Root<T> root, CriteriaQuery<?> cq, CriteriaBuilder cb) {
        From from = getFrom(property, root);
        String attr = getProperty(property);
        return cb.gt(from.get(attr), value);
    }
}
